﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>打印预览 - {{ report_name }}</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    {% load i18n admin_urls static admin_modify simpletags%}

    <script src="{% static 'webreport/CreateControl.js' %}" type="text/javascript"></script>
    <script src="{% static 'webreport/GRInstall.js' %} " type="text/javascript"></script>
    <script type="text/javascript">
        Install_InsertReport();
    </script>
</head>
<body>

<div id="content-main" class="form-main">

    <button id="content-toggle-btn" onclick="toggleReportContent()">显示</button>

    <!-- 目标内容容器：初始状态隐藏（display: none） -->
    <div id="report-content" style="display: none; margin-top: 10px;">
        报表名称  {{ report }} 报表数据 {{ data_json|safe }}
    </div>
</div>
    <script type="text/javascript">
	    var Installed = Install_Detect();
        // 显示/隐藏切换核心函数
        function toggleReportContent() {
            // 获取内容容器和按钮元素
            const contentContainer = document.getElementById("report-content");
            const toggleBtn = document.getElementById("content-toggle-btn");

            // 判断当前状态：隐藏 → 显示，显示 → 隐藏
            if (contentContainer.style.display === "none") {
                contentContainer.style.display = "block"; // 显示目标内容
                toggleBtn.innerText = "隐藏"; // 按钮文字改为“隐藏”
            } else {
                contentContainer.style.display = "none"; // 隐藏目标内容
                toggleBtn.innerText = "显示"; // 按钮文字改为“显示”
            }
        }
    </script>


<script type="text/javascript">

    // 直接使用后端序列化好的JSON字符串
    var reportData = {{ data_json|safe }};  // 使用|safe过滤器避免转义

    InsertPrintViewer({
      report: urlAddRandomNo("{{ MEDIA_URL }}{{ report }}".replace(/\\/g, '/')),
      data: reportData,


    });



   </script>

{#  <script language="javascript">#}
{##}
{#       var da={#}
{#    "Detail": [#}
{#        {"ProductID": 2,"ProductName": "牛奶","UnitPrice": 15.2,"Quantity": 20,"Amount": 304},#}
{#        {"ProductID": 16,"ProductName": "饼干","UnitPrice": 13.9,"Quantity": 35,"Amount": 486.5},#}
{#        {"ProductID": 36,"ProductName": "鱿鱼","UnitPrice": 15.2,"Quantity": 25,"Amount": 380},#}
{#        {"ProductID": 59,"ProductName": "苏澳奶酪","UnitPrice": 44,"Quantity": 30,"Amount": 1320}#}
{#    ],#}
{##}
{#    "Master": [#}
{#        {"OrderID": 10255,"CustomerId": "RICSU","CompanyName": "永大企业","Address": "港务口街 29 号"}#}
{#    ]#}
{#}#}
{#   //  InsertPrintViewer({#}
{#    //  report: urlAddRandomNo("{% static 'webreport/simple.grf' %}"),#}
{#    //  data: "{% static 'webreport/simple.xml' %}"#}
{#    //    data: da#}
{#//#}
{#   // });#}
{#  InsertDesigner({#}
{#    exparams: "<param name='OnSaveReport' value='OnSaveReport'>",#}
{#    report: urlAddRandomNo("{% static 'webreport/simple.grf' %}"),#}
{#    #}
{#    saveurl: "../General/DesignReportSave.ashx?report=2a"#}
{#  });#}
{#</script>#}



</body>
</html>
